package com.lqwu.mallchatserver.common.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 拦截器注册类
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    private TokenInterceptor tokenInterceptor;
    @Resource
    private CollectorInterceptor collectorInterceptor;
    @Resource
    private BlackInterceptor blackInterceptor;

    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        // 添加token拦截器，拦截所有/capi/** 请求
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/capi/**");
        // 添加请求收集拦截器，拦截所有/capi/** 请求
        registry.addInterceptor(collectorInterceptor)
                .addPathPatterns("/capi/**");
        // 添加黑名单拦截器，拦截所有/capi/** 请求
        registry.addInterceptor(blackInterceptor)
                .addPathPatterns("/capi/**");
    }
}
